package com.zhangqiang.git.mqttdemo.client;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

/**
 * MQ
 * 配置加载
 * 
 * @author doseng
 */
@Configuration
public class MqConfig
{
    // 消息中间件组件是否开启
    @Value("${spring.mq.run}")
    private boolean run;

    // 消息中间件组件
    @Value("${spring.mq.type}")
    private String type;

    // MQ地址
    @Value("${spring.mq.host}")
    private String host;

    // 客户端订阅标识
    @Value("${spring.mq.clientid}")
    private String clientid;

    // MQ账号
    @Value("${spring.mq.username}")
    private String username;

    // MQ密钥
    @Value("${spring.mq.password}")
    private String password;

    // MQ订阅主题集
    @Value("${spring.mq.topicFilters}")
    private String topicFilters;

    // MQ主题前缀
    @Value("${spring.mq.prefixtheme}")
    private String prefixtheme;

    // MQ超时时间 单位为秒
    @Value("${spring.mq.timeout}")
    private int timeout;

    // MQ会话心跳时间 单位为秒 服务器会每隔1.5*20秒的时间向客户端发送个消息判断客户端是否在线，但这个方法并没有重连的机制
    @Value("${spring.mq.keepalive}")
    private int keepalive;

    // MQ自动重连
    @Value("${spring.mq.automaticreconnect}")
    private boolean automaticreconnect;

    // MQ是否清空session,这里如果设置为false表示服务器会保留客户端的连接记录，设置为true表示每次连接到服务器都以新的身份连接
    @Value("${spring.mq.cleanSession}")
    private boolean cleanSession;

    // 消息质量 0发送即丢弃 1意味着消息至少被传输一次 2确保了仅仅传输接收一次
    @Value("${spring.mq.qos}")
    private int qos;

    // 最后一条数据是否永久保存,直到下一次数据覆盖
    @Value("${spring.mq.retained}")
    private boolean retained;

    public boolean isRun() {
        return run;
    }

    public void setRun(boolean run) {
        this.run = run;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getHost() {
        return host;
    }

    public void setHost(String host) {
        this.host = host;
    }

    public String getClientid() {
        return clientid;
    }

    public void setClientid(String clientid) {
        this.clientid = clientid;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getTopicFilters() {
        return topicFilters;
    }

    public void setTopicFilters(String topicFilters) {
        this.topicFilters = topicFilters;
    }

    public String getPrefixtheme() {
        return prefixtheme;
    }

    public void setPrefixtheme(String prefixtheme) {
        this.prefixtheme = prefixtheme;
    }

    public int getTimeout() {
        return timeout;
    }

    public void setTimeout(int timeout) {
        this.timeout = timeout;
    }

    public int getKeepalive() {
        return keepalive;
    }

    public void setKeepalive(int keepalive) {
        this.keepalive = keepalive;
    }

    public boolean isAutomaticreconnect() {
        return automaticreconnect;
    }

    public void setAutomaticreconnect(boolean automaticreconnect) {
        this.automaticreconnect = automaticreconnect;
    }

    public boolean isCleanSession() {
        return cleanSession;
    }

    public void setCleanSession(boolean cleanSession) {
        this.cleanSession = cleanSession;
    }

    public int getQos() {
        return qos;
    }

    public void setQos(int qos) {
        this.qos = qos;
    }

    public boolean isRetained() {
        return retained;
    }

    public void setRetained(boolean retained) {
        this.retained = retained;
    }
}
